import type { ComponentLifecycle } from 'react';
import type { CompositeValue, JSExpression, JSFunction } from './value-type';
export interface SchemaNodeType {
  /**
   * 组件名称
   */
  componentName: string;
  /**
   * 子组件
   */
  children?: string | SchemaNodeType[];
  /**
   * 组件属性
   */
  props?: any;
  /**
   * 代码拆分，子元素是否拆分为单独的文件
   */
  chunk?: ChunkConfig;
  /**
   * 容器初始数据
   */
  state?: Record<string, CompositeValue>;
  /**
   * 自定义方法
   */
  methods?: Record<string, JSFunction | JSExpression>;
  /**
   * 生命周期
   */
  lifeCycles?: Partial<Record<keyof ComponentLifecycle<any, any, any>, JSExpression | JSFunction>>;
}

export interface ChunkConfig {
  chunkName: string;
}

export enum LifeCycleIdentifiers {
  componentDidMount = 'componentDidMount',
  shouldComponentUpdate = 'shouldComponentUpdate',
  componentWillUnmount = 'componentWillUnmount',
  componentDidCatch = 'componentDidCatch',
  getSnapshotBeforeUpdate = 'getSnapshotBeforeUpdate',
  componentDidUpdate = 'componentDidUpdate',
  componentWillMount = 'componentWillMount',
  // componentWillReceiveProps = 'componentWillReceiveProps',
  // componentWillUpdate = 'componentWillUpdate',
  // UNSAFE_componentWillReceiveProps = 'UNSAFE_componentWillReceiveProps',
  // UNSAFE_componentWillUpdate = 'UNSAFE_componentWillUpdate',
}
